//
//  MainTabBarController.m
//  TableBarControllerDemo
//
//  Created by 边果互动 on 2021/3/15.
//

#import "MainTabBarController.h"
#import "HomeViewController.h"
#import "TabNoticeViewController.h"
#import "TabFindViewController.h"
#import "TabMeViewController.h"
#import "BaseNavController.h"

@interface MainTabBarController ()

@end

@implementation MainTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //给TabBar添加阴影
    self.tabBar.barStyle = UIBarStyleBlack;
    [UITabBar appearance].translucent = NO;
    [[UITabBar appearance] setBarTintColor:[UIColor whiteColor]];
    self.tabBar.layer.shadowColor = [UIColor lightGrayColor].CGColor;
    self.tabBar.layer.shadowOffset = CGSizeMake(0, -1);
    self.tabBar.layer.shadowOpacity = 0.3;
    
    NSDictionary *tabTextAttr = @{NSForegroundColorAttributeName:COLOR_MAIN};
    //添加首页
    HomeViewController *homeVC = [[HomeViewController alloc] init];
    [homeVC.view setBackgroundColor:[UIColor whiteColor]];
    homeVC.navigationItem.title = @"纺织达人";
    UIBarButtonItem *homeBarRightBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay menu:nil];
    homeVC.navigationItem.rightBarButtonItem = homeBarRightBtn;
    //    homeVC.tabBarItem.title = @"首页";
//    homeVC.tabBarItem.image =
//    homeVC.tabBarItem.selectedImage =
    BaseNavController *homeNavC = [[BaseNavController alloc] initWithRootViewController:homeVC];
    homeNavC.tabBarItem.title = @"首页";
    [homeNavC.tabBarItem setTitleTextAttributes:tabTextAttr forState:UIControlStateSelected];
    homeNavC.tabBarItem.image = [UIImage imageNamed:@"Tab_1"];
    homeNavC.tabBarItem.selectedImage = [UIImage imageNamed:@"Tab_1_sel"];
    [self addChildViewController:homeNavC];
    
    //消息
    TabNoticeViewController *noticeVC = [[TabNoticeViewController alloc] init];
    noticeVC.tabBarItem.title = @"消息";
    [noticeVC.tabBarItem setTitleTextAttributes:tabTextAttr forState:UIControlStateSelected];
    noticeVC.tabBarItem.image = [UIImage imageNamed:@"Tab_2"];
    noticeVC.tabBarItem.selectedImage = [UIImage imageNamed:@"Tab_2_sel"];
    [self addChildViewController:noticeVC];
    
    //发现
    TabFindViewController *findVC = [[TabFindViewController alloc] init];
    findVC.tabBarItem.title = @"发现";
    [findVC.tabBarItem setTitleTextAttributes:tabTextAttr forState:UIControlStateSelected];
    findVC.tabBarItem.image = [UIImage imageNamed:@"Tab_4"];
    findVC.tabBarItem.selectedImage = [UIImage imageNamed:@"Tab_4_sel"];
    [self addChildViewController:findVC];
    
    //我的
    TabMeViewController *meVC = [[TabMeViewController alloc] init];
    BaseNavController *meNavC = [[BaseNavController alloc] initWithRootViewController:meVC];
    meNavC.tabBarItem.title = @"我的";
    [meNavC.tabBarItem setTitleTextAttributes:tabTextAttr forState:UIControlStateSelected];
    meNavC.tabBarItem.image = [UIImage imageNamed:@"Tab_5"];
    meNavC.tabBarItem.selectedImage = [UIImage imageNamed:@"Tab_5_sel"];
    [self addChildViewController:meNavC];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
